/* -------------------------------------------------------------------
 *    Application class for RubiksCube
 *
 *    $File: RubiksCubeModel.h
 *    $Date: 2013/01/31 $
 *    $Revision: #1 $
 * -------------------------------------------------------------------*/
#ifndef RUBIKSCUBEMODEL
#define RUBIKSCUBEMODEL

#include <vlgSubject.h>
#include "Cuby.h"

//! enum for slice names
enum Face {RIGHT = 0, LEFT = 1, UPPER = 2, DOWN = 3, FRONT = 4, BACK = 5};

//! Model for RibuksCube
class RubiksCubeModel : public vlgSubject {
	
public:
	//! C'tor
	RubiksCubeModel(void);
	//! reset cube to initial values (colors & orientations)
	void resetCube(void);
	//! rotate right slice (R)
	void rotateRightSlice(Rotation rot);
	//! rotate middle slice (M)
	void rotateMiddleSlice(Rotation rot);
	//! rotate left slice (L)
	void rotateLeftSlice(Rotation rot);
	//! rotate upper slice (U)
	void rotateUpperSlice(Rotation rot);
	//! rotate equator slice (E)
	void rotateEquatorSlice(Rotation rot);
	//! rotate down slice (D)
	void rotateDownSlice(Rotation rot);
	//! rotate front slice (F)
	void rotateFrontSlice(Rotation rot);
	//! rotate standing slice (S)
	void rotateStandingSlice(Rotation rot);
	//! rotate back slice (B)
	void rotateBackSlice(Rotation rot);
	//! rotate entire cube on x-axis (X)
	void rotateCubeXAxis(Rotation rot);
	//! rotate entire cube on y-axis (Y)
	void rotateCubeYAxis(Rotation rot);
	//! rotate entire cube on z-axis (Z)
	void rotateCubeZAxis(Rotation rot);
	//! explode Cube ;-)
	void explode(bool increase);
	//! shuffle Cube with random rotations
	void shuffleCube(int times);
	//! getter for explosion grade
	float getExplosionGrade(void) const;
	//! subcubes building th entire RubiksCube
	Cuby cubies[3][3][3];

private:
	//! grade of explosion
	float explosionGrade;
	//! swap list of cubies
	/*!
	 *  SwapCubies is used to swap the cubies of an slice. For RubiksCube this is equivalent to
	 *  an rotation of 90 degrees.
	 */
	void swapCubies(int participants[][3], Rotation rot);
};

#endif // RUBIKSCUBEMODEL